package com.wjk.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.netflix.appinfo.InstanceInfo;
import com.netflix.discovery.EurekaClient;

@RestController
@RequestMapping("/micros-service")
public class MicroServiceHandle {

	@Autowired
	private EurekaClient  disDiscoverEurekaClient;

	@Autowired
	private RestTemplate  restTemplate;
	
	@GetMapping("detail")
	public String detail() {
		InstanceInfo instanceInfo =	disDiscoverEurekaClient.getNextServerFromEureka("micro-service-client",false);
		System.out.println(instanceInfo.getHomePageUrl());
		
		//服务之间的调用
//		restTemplate.getForObject(url,String.class);
		return instanceInfo.getHomePageUrl();
	}
	
	
}
